package com.gqb.wangyi;

import java.util.Scanner;

public class huawei1 {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		while (scanner.hasNext()) {
			int n;
			n=scanner.nextInt();
			if(n==0){
				break;
			}
			System.out.println(take(n,0));
		}
	}
	
	public static int take(int num ,int all){
		int count=num/3;
		
		if((count+num%3)==2){
			return all+count+1;
		}
		if((count+num%3)>=3){
			return all+take(count+num%3,count);
		}
		return count+all;
	}
}
